# -*- coding:utf-8 -*-

"""
双向链表
    注意：
        （1）反转核心在于next和prev域的交换
        （2）注意当前节点和上一个节点的递推
"""
class DListNode:
    def __init__(self, val):
        self.val = val
        self.prev = self.next = None

    def reverse(self, head):
        curt = None
        while head:
            curt = head
            head = curt.next
            curt.next = curt.prev
            curt.prev = head
        return curt